import pymysql

from core.config import settings


def get_db_connection() -> pymysql.connections.Connection:
    """
    获取数据库连接
    :return:
    """
    return pymysql.connect(
        host=settings.MYSQL_HOST,
        user=settings.MYSQL_USER,
        password=settings.MYSQL_PASSWORD,
        database=settings.MYSQL_DB,
        port=settings.MYSQL_PORT,
        charset=settings.MYSQL_CHARSET,
        cursorclass=pymysql.cursors.DictCursor,
    )
